<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <!-- 引入 Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="page-header">
            <h1>书籍列表</h1>
            <br>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4  column">
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增书籍</a>&nbsp;
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/allBook">显示所有书籍</a>
        </div>
        <div class="col-md-4 column"></div>
        <br>
        <div class="col-md-4 column" style="float: right;">
            <%--查询书籍--%>
            <form action="${pageContext.request.contextPath}/book/queryBook" method="post">
                <input type="text" name="queryBookName" placeholder="请输入要查询的书籍名称" required>
                <input type="submit" value="查询" class="btn btn-primary">
            </form>
        </div>
    </div>
    <br>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                    <tr>
                        <th>书籍编号</th>
                        <th>书籍名称</th>
                        <th>书籍数量</th>
                        <th>书籍详情</th>
                        <th>操作</th>
                    </tr>
                </thead>

<%--                使用foreach遍历书籍--%>
                <tbody>

                    <c:forEach var="book" items="${list}">
                        <tr>
                            <td>${book.bookId}</td>
                            <td>${book.bookName}</td>
                            <td>${book.bookCounts}</td>
                            <td>${book.detail}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/book/updateBook?id=${book.bookId}">修改</a>
                                &nbsp|&nbsp
                                <a  href="${pageContext.request.contextPath}/book/todeleteBook?id=${book.bookId}">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <h3>${err}</h3>
</div>
<script>
    function deletebook(id,loc) {
        var res=window.confirm("确认删除吗？");
        if (res){
            console.log(id+","+loc);
            // window.location.href=loc+"/book/todeleteBook?id="+id;
        }
    }
</script>

</body>
</html>
